<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <link rel="stylesheet" href="./css/登录.css">
</head>

<body>
    <div class="login-container">
        <h2>用户登录</h2>
        <form id="loginForm">
            <div class="input-group">
                <label for="username">用户名</label>
                <input type="text" id="username" name="username" required>
            </div>
            <div class="input-group">
                <label for="password">密码</label>
                <input type="password" id="password" name="password" required>
            </div>
            <button type="submit">登录</button>
        </form>
    </div>

    <script>
        document.getElementById('loginForm').addEventListener('submit', function (e) {
            e.preventDefault(); // 阻止表单默认提交行为

            // 获取输入的用户名和密码
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;

            // 这里设置正确的用户名和密码
            const correctUsername = "123456";
            const correctPassword = "123456";

            // 验证用户名和密码
            if (username === correctUsername && password === correctPassword) {
                // 验证成功，跳转到另一个页面
                window.location.href = "主页.html"; // 替换为你想要跳转的页面
            } else {
                // 验证失败，显示错误信息
                document.getElementById('errorMessage').textContent = "用户名或密码错误！";
            }
        });
    </script>
</body>

</html>